# coding=utf-8
import os
import yaml,json
yaml.warnings({'YAMLLoadWarning': False})

class ReadIni(object):
    def __init__(self, file_name=None, node=None):
        if file_name == None:
            # file_name = 'F:/A_RuanJian/Py_project/Mushishi_selenium/config/LocalElement.ini'
            dir01 = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
            self.file_name = os.path.join(dir01 + '/config/config.yaml')
        else:
            self.file_name = file_name
        # self.cf = self.get_value(file_name)

    # 加载文件
    def get_value(self):
        file_name = self.file_name
        with open(file_name, encoding="utf-8") as file_01:
            result = yaml.load(file_01)
        return result

    # 获取value得值
    # def get_value(self, key):
    #     data = self.cf.get(self.node, key)
    #     return data


if __name__ == '__main__':
    read_init = ReadIni()
    print(read_init.get_value()['register']['user_name'])

